/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.ban.jr.swb.rest.mq.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 *
 * @author Administrator
 */
public class DateUtils {
        public static String getDate(int dateTime) {
        if (dateTime < 0) {
            try {
                SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");//设置日期格式
                Calendar calendar = Calendar.getInstance(); //得到日历
                calendar.setTime(new Date());//把当前时间赋给日历
                calendar.add(Calendar.DAY_OF_MONTH, dateTime);  //设置为前一天
                String yesterdayDate = df.format(calendar.getTime());
                return yesterdayDate;
            } catch (Exception e) {
                return "";
            }
        } else {
            return getToDayDate_1();
        }

    }

    public static String getToDayDate_1() {
        SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");//设置日期格式
        String todayDate = df.format(new Date());
        return todayDate;
    }
}
